/*
============================================================================
 Name        : MyPopMenu.cpp
 Author      : 
 Copyright   : Your copyright notice
 Description : Application view implementation
============================================================================
*/

// INCLUDE FILES
#include <BARSREAD.H>
#include <coemain.h>
#include "hm_popmenu.h"
#include <EIKENV.H>
#include <eikrted.h>
#include <W32STD.H>
#include <iTest_0xE0D9648A.rsg>

#include <COEVIEW.H>

// ============================ MEMBER FUNCTIONS ===============================
#include "MyDataCenter.h"
#include <html\htmlcontrol.h>

extern CMyDataCenter* iDataCenter;
extern CHtmlControl* gHtmlControl;

// -----------------------------------------------------------------------------
// MyPopMenu::MyPopMenu()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
ChmPopMenu::ChmPopMenu()
    {
    // No implementation required

    }


// -----------------------------------------------------------------------------
// MyPopMenu::~MyPopMenu()
// Destructor.
// -----------------------------------------------------------------------------
//
ChmPopMenu::~ChmPopMenu()
    {
 
    }

	
    
void ChmPopMenu::TestMe()
{
	CEikonEnv::Static()->InfoMsg(_L("gg"));
}
    
void ChmPopMenu::PopUp(const TDesC& menures)
{
	//find the res
	
	
//	iDataCenter->LoadMemPage(iRichText1, "menu", menures);    	
//	int count = iRichText1->ListItemCount();
//	if(count == 0)
//		return;
//	
//	const CFont* font = CEikonEnv::Static()->DenseFont();
//	int fontheight = font->HeightInPixels() + 6;
//	SetSize(TSize(100, fontheight * count));
	
//	//此时listbox的尺寸是不对的，因为richeditor的尺寸已经改了。所以修正一下
//	TSize size = Size();
//	TRect tmp = CEikonEnv::Static()->ScreenDevice()->PixelsToTwips(TRect(size));
//	iRichText1->PicList()->SetOriginalSizeInTwips(tmp.Size());

//	TPoint pt(1,320-28-size.iHeight);
//	SetPosition(pt);
//	Window().SetOrdinalPosition(0); 
//	MakeVisible(true);   

	CHtmlElement* menu = gHtmlControl->Element(_L("iMenu"));
	if(menu == NULL)
		return;

	menu->SetProperty(KHStrInnerText, KNullDesC);
	gHtmlControl->InsertContentL(menu, EBeforeEnd, menures);
	
	menu->SetStyle(KHStrDisplay, KHStrVisible);	
	menu->SetProperty(KHStrScrollLoop, ETrue);

	CHtmlElement* item1 = gHtmlControl->Element(_L("menuitem"), 0);	
	gHtmlControl->SetFocusTo(item1);			
	
	gHtmlControl->RefreshAndDraw();	
}

void ChmPopMenu::HideMenu()
{
	CHtmlElement* item = gHtmlControl->Element(_L("iMenu"));
	if(item == NULL)
		return;
	item->SetStyle(KHStrDisplay, KHStrNone);	
	gHtmlControl->RefreshAndDraw();		
}
// End of File
